package com.gitee.wsl.platform.network

import com.gitee.wsl.platform.Platform
import kotlinx.coroutines.flow.Flow

/**
 * val checker = NetworkChecker()
 * LaunchedEffect(Unit) {
 *     checker.networkStatusFlow.collect { status ->
 *         println("Network changed: Connected = ${status.isConnected}, Type = ${status.networkType}")
 *     }
 * }
 */
expect class NetworkChecker() {
    suspend fun getNetworkStatus(): NetworkStatus
    val networkStatusFlow: Flow<NetworkStatus>

    companion object{
        val INSTANCE: NetworkChecker
    }
}

val Platform.Companion.networkChecker: NetworkChecker get() = NetworkChecker.INSTANCE

data class NetworkStatus(
    val isConnected: Boolean,
    val networkType: NetworkType
)

enum class NetworkType {
    WIFI, CELLULAR, ETHERNET, UNKNOWN, NONE,BLUETOOTH_TETHERING
}
